﻿@model IEnumerable<RBS.Core.Model.Hotel.H_Hotel_Img>

@{
    ViewBag.Title = "酒店图片";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script>
    $(function () {
        $(".attach-btn").click(function () {
            showAttachDialog();
        });
        $(".upload-album").each(function () {
            $(this).InitSWFUpload({ btntext: "批量上传", btnwidth: 66, single: false, water: true, thumbnail: true, filesize: "2048", sendurl: "@Url.Content("UploadImg")", flashurl: "@Url.Content("~/scripts/swfupload/swfupload.swf")", filetypes: "*.jpg;*.jpge;*.png;*.gif;" });
        }); 
      
    });
    //创建附件窗口
    function showAttachDialog(obj) {
        var objNum = arguments.length;
        var attachDialog = $.dialog({
            id: 'attachDialogId',
            lock: true,
            max: false,
            min: false,
            title: "上传附件",
            content: 'url:../Dialog/Dialog_Attach',
            width: 500,
            height: 180
        });
        //如果是修改状态，将对象传进去
        if (objNum == 1) {
            attachDialog.data = obj;
        }
    } 

    function delImgServer(obj, id) {
        //删除图片
        $.dialog.confirm("删除记录后不可恢复，您确定吗？", function () {
            var url = '@Url.Action("HotelImgDelete")?ids=' + id;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.IsSuccess) {
                        // $.dialog.alert(data.Msg);
                        delImg(obj); 


                    }
                    else {
                        //  $("#msgtip").text(data.Msg);
                        $.dialog.alert(data.Msg);
                    }
                }
            });
        }); 
    } 
    function setFocusImgById(id,hotelid,obj) {
        $.get("@Url.Action("Cover")/" + id + "?hotelid=" + hotelid, function (data) {
            if (data.IsSuccess) { 
                setFocusImg(obj);  
                var imgsrc = $(obj).children("img").eq(0).attr("src");
                // alert(imgsrc);
                $("#focusImg").attr("src", imgsrc); 

            }
            else { 
                $.dialog.alert(data.Msg);
            }
        });
     
    }
</script>

<!--导航栏-->
@{
    @Html.Partial("_Location");
}
<div class="line10"></div>
<div class="content-tab-wrap">
    <div id="floatHead" class="content-tab">
        <div class="content-tab-ul-wrap">
            <ul> 
                <li><a href="javascript:;;" onclick="tabs(this);" class="selected">酒店图片</a></li>
            </ul>
        </div>
    </div>
</div>


<div class="tab-content">
    <dl>
        <dt>酒店主图</dt>
        <dd>   
           <div class="img-box"><img id="focusImg"   alt="酒店主图" style="width:128px; height:128px; opacity:1; "  /></div> 
        </dd>
    </dl>
    <dl id="div_albums_container">
        <dt>图片相册</dt>
        <dd>
            <div class="upload-box upload-album"></div>
            <input type="hidden" name="hidFocusPhoto" id="hidFocusPhoto" class="focus-photo" /> 
            <div class="photo-list">
                <ul>
                    @if (null != ViewData.Model)
                    {
                        foreach (var item in ViewData.Model)
                        {
                            <li>
                                <input type="hidden" name="hid_photo_name" value="@item.Id|@item.ImgSrc|" />
                                <div class="img-box" onclick="setFocusImgById(@item.Id,@item.HotelId,this);">
                                 <img src="../@item.ImgSrc" bigsrc="|@item.ImgSrc" />
                                
                                    @{
                                        var imgsrc = item.ImgSrc;
                                        if (item.IsCover == 0)
                                        {
                                            <span class="remark"><i>点击设置主图</i></span>
                                        }
                                        else
                                        {
                                            <span class="remark"><i>主图</i></span> 
                                            @Html.Hidden("FocusimgSrc", "../"+item.ImgSrc);
                                            
                                        }
                                    }
                               
                                </div>
                                @*     <a href="javascript:;" onclick="setRemark(this);">描述</a>*@
                                <a href="javascript:;" onclick="delImgServer(this,@item.Id);">删除</a>
                            </li>
                        }
                    } 
                </ul>
            </div>
        </dd>
    </dl>
    <script>
      //  alert($("#FocusimgSrc").val());
        $("#focusImg").attr("src", $("#FocusimgSrc").val());
    </script>
</div>
